using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows;

namespace Faust.Andrew.MTG.Utilities
{
    public class ManaColorToBrush : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            LinearGradientBrush multiColorBrush = new LinearGradientBrush();
            multiColorBrush.StartPoint = new Point(0, 0.5);
            multiColorBrush.EndPoint = new Point(1, 0.5);
            multiColorBrush.GradientStops.Add(new GradientStop(Colors.Blue, 0));
            multiColorBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.25));
            multiColorBrush.GradientStops.Add(new GradientStop(Colors.White, 0.5));
            multiColorBrush.GradientStops.Add(new GradientStop(Colors.Green, 0.75));
            multiColorBrush.GradientStops.Add(new GradientStop(Colors.Red, 1));

            Brush brush = new SolidColorBrush(Colors.DarkGray);

            string color = value as string;

            switch (color)
            {
                case "Red":
                    brush = new SolidColorBrush(Colors.Red);
                    break;
                case "Green":
                    brush = new SolidColorBrush(Colors.Green);
                    break;
                case "Blue":
                    brush = new SolidColorBrush(Colors.Blue);
                    break;
                case "Black":
                    brush = new SolidColorBrush(Colors.Black);
                    break;
                case "White":
                    brush = new SolidColorBrush(Colors.WhiteSmoke);
                    break;
                case "Multi":
                    brush = multiColorBrush;
                    break;
                default:
                    //Leave the color set to the No-Color brush
                    break;

            }

            return brush;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}